home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************\
-
- File: sfx gestalt.c
-
- Purpose: This module handles our gestalt selector function for
- setting & getting the addresses of our fade procedure,
- shutdown proc, and restart proc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program in a file named "GNU General Public License".
- If not, write to the Free Software Foundation, 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- \**********************************************************************/
-
- #include "GestaltEQU.h"
- #include "sfx gestalt equ.h"
- #include "sfx gestalt.h"
- #include "program globals.h"
-
- short MakeNewGestaltSelectors(void)
- {
- Handle theProcHandle;
- Ptr theGestaltFunction;
- unsigned long theSize;
- OSErr gestaltError;
-
- theProcHandle=Get1Resource('PROC', 11); /* get gestalt selector function */
- if ((ResError()!=noErr) || (theProcHandle==0L))
- return kCantGetProc11Resource;
-
- if (*theProcHandle==0L)
- LoadResource(theProcHandle);
- if (*theProcHandle==0L)
- return kCantGetProc11Resource;
-
- theProcHandle=StripAddress(theProcHandle);
- *theProcHandle=StripAddress(*theProcHandle);
-
- theGestaltFunction=NewPtrSys(theSize=GetHandleSize(theProcHandle));
- if (theGestaltFunction==0L)
- return kNoMemoryInSystemHeap;
-
- theGestaltFunction=StripAddress(theGestaltFunction);
-
- BlockMove(*theProcHandle, theGestaltFunction, theSize);
- ReleaseResource(theProcHandle);
- theProcHandle=0L;
-
- gestaltError=NewGestalt(sfxGetVersion, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- gestaltError=NewGestalt(sfxGetFadeProcPtr, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- gestaltError=NewGestalt(sfxGetShutdownProcPtr, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- gestaltError=NewGestalt(sfxGetRestartProcPtr, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- gestaltError=NewGestalt(sfxGetFadeProcPtrAddress, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- gestaltError=NewGestalt(sfxGetShutdownProcPtrAddress, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- gestaltError=NewGestalt(sfxGetRestartProcPtrAddress, theGestaltFunction);
- if (gestaltError!=noErr)
- return kCantMakeNewGestalt;
-
- return allsWell;
- }
-
- short SetGestaltProcPtrs(ProcPtr fadeProcPtr, ProcPtr shutdownProcPtr,
- ProcPtr restartProcPtr)
- {
- OSErr gestaltError;
- long theAddress;
-
- gestaltError=Gestalt(sfxGetFadeProcPtrAddress, &theAddress);
- if (gestaltError!=noErr)
- return kGestaltImproperlyInstalled;
- *((ProcPtr*)theAddress)=fadeProcPtr;
-
- gestaltError=Gestalt(sfxGetShutdownProcPtrAddress, &theAddress);
- if (gestaltError!=noErr)
- return kGestaltImproperlyInstalled;
- *((ProcPtr*)theAddress)=shutdownProcPtr;
-
- gestaltError=Gestalt(sfxGetRestartProcPtrAddress, &theAddress);
- if (gestaltError!=noErr)
- return kGestaltImproperlyInstalled;
- *((ProcPtr*)theAddress)=restartProcPtr;
-
- return allsWell;
- }
-
- short GetGestaltProcPtrs(ProcPtr *fadeProcPtr, ProcPtr *shutdownProcPtr,
- ProcPtr *restartProcPtr)
- {
- OSErr gestaltError;
-
- gestaltError=Gestalt(sfxGetFadeProcPtr, fadeProcPtr);
- if (gestaltError!=noErr)
- return kGestaltImproperlyInstalled;
-
- gestaltError=Gestalt(sfxGetShutdownProcPtr, shutdownProcPtr);
- if (gestaltError!=noErr)
- return kGestaltImproperlyInstalled;
-
- gestaltError=Gestalt(sfxGetRestartProcPtr, restartProcPtr);
- if (gestaltError!=noErr)
- return kGestaltImproperlyInstalled;
-
- return allsWell;
- }
-
- Boolean sfxGestaltFunctionInstalledQQ(void)
- {
- long theVersion;
- OSErr gestaltError;
-
- gestaltError=Gestalt(sfxGetVersion, &theVersion);
- return ((gestaltError==noErr) && (theVersion==1L));
- }
-